package com.jacklei.util;

public class ArrUtil {
    public static int[] getRandomArr(){

        int length = (int) (Math.random()*100);
        int[] result = new int[length];

        for (int i = 0; i < result.length; i++) {
            result[i] = (int) ((Math.random() - Math.random())*100);
        }
        return result;
    }
    public static int[] copyArr(int[] arr){
        int[] result = new int[arr.length];
        for (int i = 0; i < arr.length; i++) {
            result[i] = arr[i];
        }
        return result;
    }
    public static void seeArr(int[] arr1, int[] arr2){
        System.out.println("arr1==>");
        for (int i : arr1) {
            System.out.print(i+"，");
        }
        System.out.println();
        System.out.println("arr2==>");
        for (int i : arr2) {
            System.out.print(i+"，");
        }
    }
    public static void swap(int[] arr, int a, int b){
        if(a == b) return;
        arr[a] = arr[a] ^ arr[b];
        arr[b] = arr[a] ^ arr[b];
        arr[a] = arr[a] ^ arr[b];
    }
    public static void checkArr(int[] arr1, int[] arr2){
        for (int i = 0; i < arr1.length; i++) {
            if(arr1[i] != arr2[i]) {
                System.out.println("fail！！！！ i:" + i+" => arr1:" + arr1[i] + " =>arr2:" + arr2[i]);
                break;
            }
            if (i == arr1.length-1) System.out.println("successful");
        }
    }
}
